"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
    return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (g && (g = 0, op[0] && (_ = 0)), _) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
        if (ar || !(i in from)) {
            if (!ar) ar = Array.prototype.slice.call(from, 0, i);
            ar[i] = from[i];
        }
    }
    return to.concat(ar || Array.prototype.slice.call(from));
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var pictureController_1 = require("@/api/pictureController");
var ant_design_vue_1 = require("ant-design-vue");
var vue_1 = require("vue");
var vue_router_1 = require("vue-router");
var PictureList_vue_1 = __importDefault(require("@/components/PictureList.vue"));
var router = (0, vue_router_1.useRouter)();
// 数据  
var dataList = (0, vue_1.ref)([]);
var total = (0, vue_1.ref)(0);
var loading = (0, vue_1.ref)(true);
var categoryList = (0, vue_1.ref)([]);
var selectedCategory = (0, vue_1.ref)('all');
var tagList = (0, vue_1.ref)([]);
var selectedTagList = (0, vue_1.ref)([]);
// 搜索条件  
var searchParams = (0, vue_1.reactive)({
    current: 1,
    pageSize: 12,
    sortField: 'createTime',
    sortOrder: 'descend',
});
// 分页参数  
var pagination = (0, vue_1.computed)(function () {
    var _a, _b;
    return {
        current: (_a = searchParams.current) !== null && _a !== void 0 ? _a : 1,
        pageSize: (_b = searchParams.pageSize) !== null && _b !== void 0 ? _b : 10,
        total: total.value,
        // 切换页号时，会修改搜索参数并获取数据  
        onChange: function (page, pageSize) {
            searchParams.current = page;
            searchParams.pageSize = pageSize;
            fetchData();
        },
    };
});
// 页面加载时请求一次  
(0, vue_1.onMounted)(function () {
    fetchData();
});
var doSearch = function () {
    // 重置搜索条件  
    searchParams.current = 1;
    fetchData();
};
// 获取标签和分类选项  
var getTagCategoryOptions = function () { return __awaiter(void 0, void 0, void 0, function () {
    var res;
    var _a, _b;
    return __generator(this, function (_c) {
        switch (_c.label) {
            case 0: return [4 /*yield*/, (0, pictureController_1.listPictureTagCategoryUsingGet)()];
            case 1:
                res = _c.sent();
                if (res.data.code === 0 && res.data.data) {
                    // 转换成下拉选项组件接受的格式  
                    categoryList.value = (_a = res.data.data.categoryList) !== null && _a !== void 0 ? _a : [];
                    tagList.value = (_b = res.data.data.tagList) !== null && _b !== void 0 ? _b : [];
                }
                else {
                    ant_design_vue_1.message.error('加载分类标签失败，' + res.data.message);
                }
                return [2 /*return*/];
        }
    });
}); };
(0, vue_1.onMounted)(function () {
    getTagCategoryOptions();
});
// 获取数据
var fetchData = function () { return __awaiter(void 0, void 0, void 0, function () {
    var params, res;
    var _a, _b;
    return __generator(this, function (_c) {
        switch (_c.label) {
            case 0:
                loading.value = true;
                params = __assign(__assign({}, searchParams), { tags: [] });
                if (selectedCategory.value !== 'all') {
                    params.category = selectedCategory.value;
                }
                selectedTagList.value.forEach(function (useTag, index) {
                    if (useTag) {
                        params.tags.push(tagList.value[index]);
                    }
                });
                return [4 /*yield*/, (0, pictureController_1.listPictureVoByPageUsingPost)(params)];
            case 1:
                res = _c.sent();
                if (res.data.data) {
                    dataList.value = (_a = res.data.data.records) !== null && _a !== void 0 ? _a : [];
                    total.value = (_b = res.data.data.total) !== null && _b !== void 0 ? _b : 0;
                }
                else {
                    ant_design_vue_1.message.error('获取数据失败，' + res.data.message);
                }
                loading.value = false;
                return [2 /*return*/];
        }
    });
}); };
// 跳转至图片详情  
var doClickPicture = function (picture) {
    router.push({
        path: "/picture/".concat(picture.id),
    });
}; /* PartiallyEnd: #3632/scriptSetup.vue */
function __VLS_template() {
    var __VLS_ctx = {};
    var __VLS_components;
    var __VLS_directives;
    // CSS variable injection 
    // CSS variable injection end 
    __VLS_elementAsFunction(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)({
        id: ("homePage"),
    });
    __VLS_elementAsFunction(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)(__assign({ class: ("search-bar") }));
    var __VLS_0 = {}.AInputSearch;
    /** @type { [typeof __VLS_components.AInputSearch, typeof __VLS_components.aInputSearch, ] } */ ;
    // @ts-ignore
    var __VLS_1 = __VLS_asFunctionalComponent(__VLS_0, new __VLS_0(__assign({ 'onSearch': {} }, { placeholder: ("从海量图片中搜索"), value: ((__VLS_ctx.searchParams.searchText)), enterButton: ("搜索"), size: ("large") })));
    var __VLS_2 = __VLS_1.apply(void 0, __spreadArray([__assign({ 'onSearch': {} }, { placeholder: ("从海量图片中搜索"), value: ((__VLS_ctx.searchParams.searchText)), enterButton: ("搜索"), size: ("large") })], __VLS_functionalComponentArgsRest(__VLS_1), false));
    var __VLS_6;
    var __VLS_7 = {
        onSearch: (__VLS_ctx.doSearch)
    };
    var __VLS_3;
    var __VLS_4;
    var __VLS_5;
    var __VLS_8 = {}.ATabs;
    /** @type { [typeof __VLS_components.ATabs, typeof __VLS_components.aTabs, typeof __VLS_components.ATabs, typeof __VLS_components.aTabs, ] } */ ;
    // @ts-ignore
    var __VLS_9 = __VLS_asFunctionalComponent(__VLS_8, new __VLS_8(__assign({ 'onChange': {} }, { activeKey: ((__VLS_ctx.selectedCategory)) })));
    var __VLS_10 = __VLS_9.apply(void 0, __spreadArray([__assign({ 'onChange': {} }, { activeKey: ((__VLS_ctx.selectedCategory)) })], __VLS_functionalComponentArgsRest(__VLS_9), false));
    var __VLS_14;
    var __VLS_15 = {
        onChange: (__VLS_ctx.doSearch)
    };
    var __VLS_11;
    var __VLS_12;
    var __VLS_16 = {}.ATabPane;
    /** @type { [typeof __VLS_components.ATabPane, typeof __VLS_components.aTabPane, ] } */ ;
    // @ts-ignore
    var __VLS_17 = __VLS_asFunctionalComponent(__VLS_16, new __VLS_16({
        key: ("all"),
        tab: ("全部"),
    }));
    var __VLS_18 = __VLS_17.apply(void 0, __spreadArray([{
            key: ("all"),
            tab: ("全部"),
        }], __VLS_functionalComponentArgsRest(__VLS_17), false));
    for (var _i = 0, _a = __VLS_getVForSourceType((__VLS_ctx.categoryList)); _i < _a.length; _i++) {
        var category = _a[_i][0];
        var __VLS_22 = {}.ATabPane;
        /** @type { [typeof __VLS_components.ATabPane, typeof __VLS_components.aTabPane, ] } */ ;
        // @ts-ignore
        var __VLS_23 = __VLS_asFunctionalComponent(__VLS_22, new __VLS_22({
            key: ((category)),
            tab: ((category)),
        }));
        var __VLS_24 = __VLS_23.apply(void 0, __spreadArray([{
                key: ((category)),
                tab: ((category)),
            }], __VLS_functionalComponentArgsRest(__VLS_23), false));
    }
    __VLS_13.slots.default;
    var __VLS_13;
    __VLS_elementAsFunction(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)(__assign({ class: ("tag-bar") }));
    __VLS_elementAsFunction(__VLS_intrinsicElements.span, __VLS_intrinsicElements.span)(__assign({ style: ({}) }));
    var __VLS_28 = {}.ASpace;
    /** @type { [typeof __VLS_components.ASpace, typeof __VLS_components.aSpace, typeof __VLS_components.ASpace, typeof __VLS_components.aSpace, ] } */ ;
    // @ts-ignore
    var __VLS_29 = __VLS_asFunctionalComponent(__VLS_28, new __VLS_28({
        size: (([0, 8])),
        wrap: (true),
    }));
    var __VLS_30 = __VLS_29.apply(void 0, __spreadArray([{
            size: (([0, 8])),
            wrap: (true),
        }], __VLS_functionalComponentArgsRest(__VLS_29), false));
    for (var _b = 0, _c = __VLS_getVForSourceType((__VLS_ctx.tagList)); _b < _c.length; _b++) {
        var _d = _c[_b], tag = _d[0], index = _d[1];
        var __VLS_34 = {}.ACheckableTag;
        /** @type { [typeof __VLS_components.ACheckableTag, typeof __VLS_components.aCheckableTag, typeof __VLS_components.ACheckableTag, typeof __VLS_components.aCheckableTag, ] } */ ;
        // @ts-ignore
        var __VLS_35 = __VLS_asFunctionalComponent(__VLS_34, new __VLS_34(__assign({ 'onChange': {} }, { key: ((tag)), checked: ((__VLS_ctx.selectedTagList[index])) })));
        var __VLS_36 = __VLS_35.apply(void 0, __spreadArray([__assign({ 'onChange': {} }, { key: ((tag)), checked: ((__VLS_ctx.selectedTagList[index])) })], __VLS_functionalComponentArgsRest(__VLS_35), false));
        var __VLS_40 = void 0;
        var __VLS_41 = {
            onChange: (__VLS_ctx.doSearch)
        };
        var __VLS_37 = void 0;
        var __VLS_38 = void 0;
        (tag);
        __VLS_39.slots.default;
        var __VLS_39;
    }
    __VLS_33.slots.default;
    var __VLS_33;
    // @ts-ignore
    /** @type { [typeof PictureList, ] } */ ;
    // @ts-ignore
    var __VLS_42 = __VLS_asFunctionalComponent(PictureList_vue_1.default, new PictureList_vue_1.default({
        dataList: ((__VLS_ctx.dataList)),
        loading: ((__VLS_ctx.loading)),
    }));
    var __VLS_43 = __VLS_42.apply(void 0, __spreadArray([{
            dataList: ((__VLS_ctx.dataList)),
            loading: ((__VLS_ctx.loading)),
        }], __VLS_functionalComponentArgsRest(__VLS_42), false));
    var __VLS_47 = {}.APagination;
    /** @type { [typeof __VLS_components.APagination, typeof __VLS_components.aPagination, ] } */ ;
    // @ts-ignore
    var __VLS_48 = __VLS_asFunctionalComponent(__VLS_47, new __VLS_47(__assign(__assign({ 'onChange': {} }, { style: ({}) }), { current: ((__VLS_ctx.searchParams.current)), pageSize: ((__VLS_ctx.searchParams.pageSize)), total: ((__VLS_ctx.total)) })));
    var __VLS_49 = __VLS_48.apply(void 0, __spreadArray([__assign(__assign({ 'onChange': {} }, { style: ({}) }), { current: ((__VLS_ctx.searchParams.current)), pageSize: ((__VLS_ctx.searchParams.pageSize)), total: ((__VLS_ctx.total)) })], __VLS_functionalComponentArgsRest(__VLS_48), false));
    var __VLS_53;
    var __VLS_54 = {
        onChange: (__VLS_ctx.onPageChange)
    };
    var __VLS_50;
    var __VLS_51;
    var __VLS_52;
    ['search-bar', 'tag-bar',];
    var __VLS_slots;
    var $slots;
    var __VLS_inheritedAttrs;
    var $attrs;
    var __VLS_refs = {};
    var $refs;
    var $el;
    return {
        attrs: {},
        slots: __VLS_slots,
        refs: $refs,
        rootEl: $el,
    };
}
;
var __VLS_self = (await Promise.resolve().then(function () { return __importStar(require('vue')); })).defineComponent({
    setup: function () {
        return {
            PictureList: PictureList_vue_1.default,
            dataList: dataList,
            total: total,
            loading: loading,
            categoryList: categoryList,
            selectedCategory: selectedCategory,
            tagList: tagList,
            selectedTagList: selectedTagList,
            searchParams: searchParams,
            doSearch: doSearch,
        };
    },
});
exports.default = (await Promise.resolve().then(function () { return __importStar(require('vue')); })).defineComponent({
    setup: function () {
        return {};
    },
    __typeEl: {},
});
; /* PartiallyEnd: #4569/main.vue */
